package de.koller.worlders.engine.tiles.background;

import de.koller.oceanFramework.util.ColorIntUtil;
import java.util.Random;

public class NightSky extends Background {

	private static Random rnd = new Random();
	
	@Override
	protected void init() {
		super.init();
		
		texture.clear( 0xff000000 );
		generate();
		texture.flush();

//		horizon.clear( 0x00000000 );
//		for( int x = 0; x < 1024; x++ )
//			for( int y = 512; y < 1024; y++ )
//				horizon.setPixel( 0xff00ff00, x, y );
//		horizon.flush();
	}
	
	private void generate() {
		for( int i = 0; i < 1000; i++ )
			addStar( rnd.nextInt( 798 ) + 1, rnd.nextInt( 598 ) + 1 );
	}

	private void addStar( int x, int y ) {
		int c = rnd.nextInt( 0xff );
		int cl = c - 128;
		if( cl < 0 ) cl = 0;
		
		int r = ColorIntUtil.getIntColor( 0xff, c, c, c );
		int rl = ColorIntUtil.getIntColor( 0xff, cl, cl, cl );
		
		texture.setPixel( r, x, y );
		texture.setPixel( rl, x+1, y );
		texture.setPixel( rl, x-1, y );
		texture.setPixel( rl, x, y+1 );
		texture.setPixel( rl, x, y-1 );
	}
	
}
